import { http } from "@/utils/request";

// 获取所有角色
export const getAllRolesAPI = (token: string) => {
  return http.get("/roles", {
    headers: {
      Authorization: `Bearer ${token}`, // 在请求头中携带 token
    },
  });
};

// 添加角色
export const addRoleAPI = (token: string, data: any) => {
  return http.post("/roles", data, {
    headers: { Authorization: `Bearer ${token}` },
  });
};

// 更新角色
export const updateRoleAPI = (token: string, id: number, data: any) => {
  return http.put(`/roles/${id}`, data, {
    headers: { Authorization: `Bearer ${token}` },
  });
};

// 删除角色
export const deleteRoleAPI = (token: string, id: number) => {
  return http.delete(`/roles/${id}`, {
    headers: { Authorization: `Bearer ${token}` },
  });
};

// 获取单个角色
export const getRoleAPI = (token: string, id: number) => {
  return http.get(`/roles/${id}`, {
    headers: { Authorization: `Bearer ${token}` },
  });
};
